//
//  TKYQuelityDetileController.m
//  StationHouseHelper
//
//  Created by apple on 2018/8/10.
//  Copyright © 2018年 铁科院. All rights reserved.
//

#import "TKYQuelityDetileController.h"
#import "TKYTitleTextView.h"
#import "TKYDesView.h"
#import "TKYTitleTextField.h"
#import "TKYAddImageOrVideoView.h"
#import "TKYDataConnectionView.h"
@interface TKYQuelityDetileController ()
{
    UIView *view;
    UIView *_supDataView;
}

@property (nonatomic, strong)UIScrollView *scrollV;

/** 任务标题*/
@property (nonatomic, strong) TKYTitleTextField *titleView;
/**类型*/
@property (nonatomic, strong) TKYTitleTextView *typeView;
/**问题级别*/
@property (nonatomic, strong) TKYTitleTextField *questionLevelView;
/**考核分数*/
@property (nonatomic, strong) TKYTitleTextField *scoreView;
/**问题描述*/
@property (nonatomic, strong) TKYDesView *questionDesView;
/**措施要求*/
@property (nonatomic, strong) TKYDesView *measuresRequiredView;
/**照片或视频*/
@property (nonatomic, strong) TKYAddImageOrVideoView *imageVideoView;
/**截至日期*/
@property (nonatomic, strong) TKYTitleTextField *dateView;
/**资料模型label*/
@property (nonatomic, strong) UILabel *dataLabel;

/**资料关联*/
@property (nonatomic, strong) TKYDataConnectionView *dadaView;
/**模型关联*/
//@property (nonatomic, strong) TKYTitleTextField *questionLevelView;
/**分部分项*/
@property (nonatomic, strong) TKYTitleTextField *subdivisionView;
/**相关人员label*/
@property (nonatomic, strong) UILabel *personLabel;
@property (nonatomic, strong)UIView *personView;
/**责任人*/
@property (nonatomic, strong) TKYTitleTextField *liablePersonlView;
/**督办人*/
@property (nonatomic, strong) TKYTitleTextField *supervisorView;
/**验收人*/
@property (nonatomic, strong) TKYTitleTextField *acceptorView;
/**抄送人*/
@property (nonatomic, strong) TKYTitleTextField *ccPersonView;

@end

@implementation TKYQuelityDetileController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupUI];
    // Do any additional setup after loading the view.
}

/**
 设置界面
 */
- (void)setupUI{
    self.navigationItem.title = @"质量详情";
    self.navigationController.navigationBar.barTintColor = KNavColor;
    self.navigationController.navigationBar.tintColor = [UIColor whiteColor];
    [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor],NSFontAttributeName:[UIFont systemFontOfSize:19.0]}];
    
    [self initUI];
}

/**
 返回按钮*/
- (void)backButton:(UIBarButtonItem *)barButtonItem{
    [self dismissViewControllerAnimated:YES completion:nil];
}

- (void)initUI{
    self.view.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.scrollV];
    
    __weak typeof(self) weakSelf = self;
    __weak typeof(view) weakView = view;
    
    //任务标题
    self.titleView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kHeightScale *44) titleLabelText:@"任务标题" placeholderText:@""];
    self.titleView.textField.userInteractionEnabled = NO;
    self.titleView.textField.text = @"任务标题";
    self.titleView.selectedButton.hidden = YES;
    self.titleView.imageV.hidden = YES;
    
    [self.scrollV addSubview:self.titleView];
    //类型
    self.typeView = [[TKYTitleTextView alloc]initWithFrame:CGRectMake(0, self.titleView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"类型" placeholderText:@""];
    self.typeView.imageV.hidden = YES;
    self.typeView.contentLabel.text = @"类型";
    [self.scrollV addSubview:self.typeView];
    
    //类型往下的view 放到了这个view上, 为了点击类型选择改变view的位置
    view = [[UIView alloc]initWithFrame:CGRectMake(0, self.typeView.kx_bottom, kScreenWidth, kHeightScale *44 *3 +kHeightScale *350)];
    [self.scrollV addSubview:view];
    
    //问题级别
    self.questionLevelView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kHeightScale *44) titleLabelText:@"问题级别" placeholderText:@""];
    self.questionLevelView.textField.userInteractionEnabled = NO;
    self.questionLevelView.textField.text = @"I级";
    self.questionLevelView.imageV.hidden = YES;
    [view addSubview:self.questionLevelView];
    
    //考核分数
    self.scoreView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.questionLevelView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"考核分数" placeholderText:@""];
    self.scoreView.textField.userInteractionEnabled = NO;
    self.scoreView.textField.text = @"5";
    self.scoreView.selectedButton.hidden = YES;
    self.scoreView.imageV.hidden = YES;
    self.scoreView.textField.keyboardType = UIKeyboardTypeNumberPad;
    [view addSubview:self.scoreView];
    
    
    //问题描述
    self.questionDesView = [[TKYDesView alloc]initWithFrame:CGRectMake(0, self.scoreView.kx_bottom, kScreenWidth, kHeightScale *100) titleLabelText:@"问题描述"];
    self.questionDesView.textView.userInteractionEnabled = NO;
    self.questionDesView.textView.text = @"问题描述问题描述问题描述问题描述问题描述问题描述问题描述";
    [view addSubview:self.questionDesView];
    
    //措施要求
    self.measuresRequiredView = [[TKYDesView alloc]initWithFrame:CGRectMake(0, self.questionDesView.kx_bottom, kScreenWidth, kHeightScale *100) titleLabelText:@"措施要求" ];
    self.measuresRequiredView.textView.userInteractionEnabled = NO;
    self.measuresRequiredView.textView.text = @"措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求措施要求";
    [view addSubview:self.measuresRequiredView];
    
    //照片或视频
    self.imageVideoView = [[TKYAddImageOrVideoView alloc]initWithFrame:CGRectMake(0, self.measuresRequiredView.kx_bottom, kScreenWidth, kHeightScale *150) ];
    self.imageVideoView.cameraButton.hidden = YES;
    self.imageVideoView.imageArr = @[].copy;
    self.imageVideoView.seletetedCollectionCellBlock = ^(NSIndexPath *indexPath) {
//        NSInteger indexChain = indexPath.row;
//        [GQImageVideoViewer sharedInstance]
//        .videoViewClassNameChain(@"TKYVideoView")
//        .dataArrayChain(weakSelf.imageArrM)
//        .showIndexTypeChain(GQShowIndexTypeLabel)
//        .selectIndexChain(indexChain)
//        .achieveSelectIndexChain(^(NSInteger selectIndex){
//            NSLog(@"%zd",selectIndex);
//        })
//        .launchDirectionChain(GQLaunchDirectionRight)
//        .showViewChain(weakSelf.navigationController.view);
    };
    [view addSubview:self.imageVideoView];
    
    //截至日期
    self.dateView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.imageVideoView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"截至日期" placeholderText:@""];
    self.dadaView.imageV.hidden = YES;
    self.dateView.textField.text = @"2018-7-8";
    [view addSubview:self.dateView];
    //资料模型的view
    [self initDataModelView];
    [self initPersonView];
}

//资料模型
- (void)initDataModelView{
    self.dataLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, view.kx_bottom, kScreenWidth, kHeightScale*30)];
    self.dataLabel.backgroundColor = kMainColour;
    self.dataLabel.text = @"  资料关联";
    self.dataLabel.font = Font(12);
    [self.scrollV addSubview:self.dataLabel];
    
    //资料关联
    self.dadaView = [[TKYDataConnectionView alloc]initWithFrame:CGRectMake(0, self.dataLabel.kx_bottom, kScreenWidth, kHeightScale *60)];
    self.dadaView.selectedBtn.hidden = YES;
    self.dadaView.imageV.hidden = YES;
    self.dadaView.deleteButton.hidden = YES;
    self.dadaView.contentLabel.text = @"sdsf.doc";
    
    [self.scrollV addSubview:self.dadaView];
    
    //    //模型关联
    //    self.questionDesView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.questionLevelView.kx_bottom, kScreenWidth, kHeightScale *40) titleLabelText:@"问题描述" placeholderText:@"请选择"];
    //    self.questionLevelView.selectedButtonBlock = ^(UIButton *button) {
    //        NSLog(@"123");
    //    };
    //    [self.scrollV addSubview:self.questionDesView];
    
    //分部分项
    self.subdivisionView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.dadaView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"分部分项" placeholderText:@""];
    self.subdivisionView.imageV.hidden = YES;
    self.subdivisionView.textField.text = @"分部分项";

    [self.scrollV addSubview:self.subdivisionView];
}


/**相关人员 */
- (void)initPersonView{
    __weak typeof(self) weakSelf = self;
    self.personView = [[UIView alloc]initWithFrame:CGRectMake(0,self.subdivisionView.kx_bottom, kScreenWidth, kHeightScale*300)];
    [self.scrollV addSubview:self.personView];
    
    self.personLabel = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kHeightScale*30)];
    self.personLabel.text = @"   相关人员";
    self.personLabel.font = Font(12);
    self.personLabel.backgroundColor = kMainColour;
    [self.personView addSubview:self.personLabel];
    //责任人
    self.liablePersonlView= [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.personLabel.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"责任人" placeholderText:@""];
    self.liablePersonlView.imageV.hidden = YES;
    self.liablePersonlView.textField.text = @"责任人";
    [self.personView addSubview:self.liablePersonlView];
    
    //督办人
    self.supervisorView= [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.liablePersonlView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"督办人" placeholderText:@""];
    self.supervisorView.imageV.hidden = YES;
    self.supervisorView.textField.text = @"督办人";
    [self.personView addSubview:self.supervisorView];
    
    //验收人
    self.acceptorView = [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.supervisorView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"验收人" placeholderText:@""];
    self.acceptorView.imageV.hidden = YES;
    self.acceptorView.textField.text = @"验收人";
    
    [self.personView addSubview:self.acceptorView];
    
    //抄送人
    self.ccPersonView= [[TKYTitleTextField alloc]initWithFrame:CGRectMake(0, self.acceptorView.kx_bottom, kScreenWidth, kHeightScale *44) titleLabelText:@"抄送人" placeholderText:@""];
    self.ccPersonView.imageV.hidden = YES;
    self.ccPersonView.textField.text = @"抄送人";
    [self.personView addSubview:self.ccPersonView];
}

- (UIScrollView *)scrollV {
    if (_scrollV == nil) {
        self.automaticallyAdjustsScrollViewInsets = NO;
        _scrollV = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight )];
        _scrollV.scrollEnabled = YES;
        //_scrollV.pagingEnabled = YES;
        _scrollV.showsHorizontalScrollIndicator = NO;
        _scrollV.showsVerticalScrollIndicator = YES;
        _scrollV.contentSize = CGSizeMake(0, kScreenHeight *1 +kHeightScale *300);
    }
    return _scrollV;
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}



@end
